package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.dto.UserDto;
import com.zzyl.entity.User;
import com.zzyl.vo.UserAddVo;
import com.zzyl.vo.UserVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface UserMapper {

    int deleteByPrimaryKey(Long id);

    int insert(User record);

    int insertSelective(User record);

    User selectByPrimaryKey(Long id);

    int updateByPrimaryKeySelective(User record);

    int updateByPrimaryKey(User record);

    /**
     * 这是Mybatis Generator拓展插件生成的方法(请勿删除).
     * This method corresponds to the database table sys_user
     *
     * @mbg.generated
     * @author hewei
     */
    int batchInsert(@Param("list") List<User> list);

    /**
     * 用户列表查询
     * @param realName
     * @return
     */
    @Select("select * from zzyl.sys_user where data_state = 0 and real_name = #{realName}")
    List<UserVo> selectAll(String realName);

    /**
     * 分页查询用户
     * @param userDto
     * @return
     */
    Page<UserVo> pageInfo(UserDto userDto);

    /**
     * 修改用户
     * @param user
     * @return
     */
    Integer update(User user);

    /**
     * 逻辑删除用户
     * @param userIds
     */
    @Update("update zzyl.sys_user set is_delete = 1 where id = #{userIds}")
    void setDeleteState(Long userIds);

    /**
     * 根据部门编号查询用户
     * @param deptNo
     * @return
     */
    @Select("select * from zzyl.sys_user where dept_no = #{deptNo} ")
    List<User> selectUserByDeptNo(String deptNo);

    /**
     * 根据岗位编号查询用户
     * @param postNo
     * @return
     */
    @Select("select * from zzyl.sys_user where post_no = #{postNo} ")
    User selectUserByPostNo(String postNo);

    /**
     * 根据用户名查询用户
     * @param username
     * @return
     */
    @Select("select * from zzyl.sys_user where username = #{username} ")
    User selectUserByUsername(String username);
}